﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1.ChatRoom
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            
            if (Session["Name"] == null)
            {
               Response.Redirect("WebForm2.aspx");             
            }
            if (Application["Room"]==null)
            {
                Application["Room"] = new Panel();
            }          
            Panel1.Controls.Add((Panel)Application["Room"]);
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string name = Session["Name"].ToString();
            string time = System.DateTime.Now.ToString();
            string info = TextBox1.Text;
            //Literal     L  = new Literal();
            Literal1.Text = time + "<br/>" + name + " :" + info;
            ((Panel)Application["Room"]).Controls.Add(Literal1);

        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Session["Name"] = null;
            Session.Abandon();
            Response.Redirect("WebForm2.aspx");
        }
    }
}